package com.sx.gongzhong.pest;

import android.content.Context;

import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.MessageBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.model.BasePageListBean;
import com.sx.gongzhong.view.MessageDynamicView;

import java.util.Map;

/**动态信息
 * Created by admin on 2018/1/3.
 */

public class MessageDynamicPest {
    private MessageDynamicView messageDynamicView;

    public MessageDynamicPest(MessageDynamicView messageDynamicView) {
        this.messageDynamicView = messageDynamicView;
    }
    public void getData(Context context, int page, int rows){
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("page",page);
        map.put("rows",rows);
        new ApiManager().getMessageDynamicListData(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<MessageBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<MessageBean>> response) {
                messageDynamicView.getSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                messageDynamicView.showError(message);
            }
        });
    }
    public void deleteMessageDynamic(String ids){
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("ids",ids);
        new ApiManager().deleteMessageDynamic(map, new BaseCallBack<ReplyUserBean.BaseResult<Boolean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Boolean> response) {
                messageDynamicView.deleteMessageDynamicSuccess("删除成功");
            }
            @Override
            public void onFailures(String message) {
                messageDynamicView.showError(message);
            }
        });
    }

    public void readMessageDynamic(String ids){
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("ids",ids);
        new ApiManager().readMessageDynamic(map, new BaseCallBack<ReplyUserBean.BaseResult<Boolean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Boolean> response) {
                messageDynamicView.deleteMessageDynamicSuccess("");
            }
            @Override
            public void onFailures(String message) {
                messageDynamicView.showError(message);
            }
        });
    }
}
